#################################### 函数库
from flask import Flask
from flask import render_template
from flask import request

import json
import ADS

#################################### Flask进程

app = Flask(__name__) 


@app.route('/')
def adsmain():
    return render_template('main.html')


#################################### 处理数据
@app.route('/1/')
def Process():
    while(1):
        ADS.Process()
    return 'ok'


#################################### 读取数据进程
@app.route('/2/')
def ReadRx():
    while(1):
        ADS.ReadRx()
    return 'ok'


####################################
@app.route('/3/')
def ShowMap():
    return render_template('map.html')


@app.route('/getdata/',methods=["GET","POST"])
def getName():
    if request.method == 'GET':
        try:
            stores['features'] = ADS.TransMess()
        except:
            return json.dumps({'type':'get data failure'}, ensure_ascii=False)
        else:
            return json.dumps(stores, ensure_ascii=False)


stores = {
    'type': "FeatureCollection",
    'features': 
    [
    ],
}

if __name__ == "__main__":
    app.run(threaded=True)



